# Maintainer: Rafal Brzegowy <rafal.brzegowy@yahoo.com>

_realname=lis
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.0.32
pkgrel=2
pkgdesc='Library of Iterative Solvers for linear systems (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
depends=("${MINGW_PACKAGE_PREFIX}-libtool"
         "${MINGW_PACKAGE_PREFIX}-msmpi")
makedepends=("${MINGW_PACKAGE_PREFIX}-msmpi")
options=('!docs')
license=('BSD')
url='https://www.ssisc.org/lis/'
source=(https://www.ssisc.org/lis/dl/${_realname}-${pkgver}.zip)
sha256sums=('93C515E1B38C9263D464F1C86773253A437FE973643618A6099FE0829E5C30D4')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  autoreconf -fiv
}

build() {
  cd "${srcdir}"
  [[ -d "build-${MSYSTEM}" ]] && rm -rf "build-${MSYSTEM}"
  cp -r "${_realname}-${pkgver}" "build-${MSYSTEM}"

  cd "build-${MSYSTEM}"
  declare -a extra_conf
  case ${MSYSTEM} in
    CLANG*)
      extra_conf+=("--disable-f90 --disable-fortran");;
    *)
      extra_conf+=("--enable-f90 --enable-fortran");;
  esac

  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-mpi \
    --enable-omp \
    --enable-shared \
    --enable-fma \
    --enable-sse2 \
    --enable-longlong \
    --enable-longdouble \
    --enable-quad \
    --disable-test \
    --with-gnu-ld \
    ${extra_conf}

  make
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"
  make check || true
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make install DESTDIR="${pkgdir}"

  install -Dm644 COPYING ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}

# vim: ts=2 sw=2 et:
